<%@ taglib uri="/WEB-INF/myfaces_html.tld" 	prefix="h" %>
<%@ taglib uri="/WEB-INF/myfaces_core.tld" 	prefix="f" %>
<%@ taglib uri="/WEB-INF/tomahawk.tld"     	prefix="t" %>
<%@ taglib uri="/WEB-INF/myfaces_sandbox.tld"   prefix="s" %>
<%@ page import="java.util.ArrayList" %>

<f:view>
    <jsp:include page="/intestazione.jsp">
        <jsp:param name="titolo" value="Gestione Scadenziario"/>
    </jsp:include>
    <jsp:include page="/menu.jsp"/>
    <script language="javascript" src="./script/popup_full_center.js"></script>
    <script language="javascript" src="./script/ripristinoSessione.js"></script>
    <h:form binding="#{dettaglioScadenziario.form}">    

        <table class="find" style="border: 2pt solid white; margin-bottom: 5px">
            <hr />
            <tr>  
                <td class="intestazionePagina" align="center">
                <strong> SCADENZIARIO </strong></td>                        
            </tr>        
        </table>
        
        <table class="dettaglio">
            <tbody>     
                <tr>     
                    <td>
                        <h:commandLink styleClass="commandLink_Style" dir="RTL" action="benvenuto" immediate="true">
                            <t:graphicImage url="/image/go-home.png" border="0"/>
                        </h:commandLink>              
                    </td>   
                </tr>
                <tr>
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="dataDa" value="Da data:"/></strong></td>
                    <td><h:outputText value=" (gg/mm/aaaa)" style="font-size:6.5pt"/>
                        <br/>
                        <t:inputCalendar id="dataDa" renderAsPopup="true" renderPopupButtonAsImage="true" popupDateFormat="dd/MM/yyyy" size="10" maxlength="10" styleClass="campoTesto" value="#{beanScadenziario.dataDa}" required="true">
                            <s:convertDateTime type="date" pattern="dd/MM/yyyy"/>
                        </t:inputCalendar>
                        <br/>
                        <h:message style="color: red; font-size: 8pt" for="dataDa" showDetail="true" showSummary="false" />
                    </td>
                </tr>
                <tr>
                    <td class="etichettaDettaglio"><strong><t:outputLabel for="dataA" value="A data:"/></strong></td>
                    <td><h:outputText value=" (gg/mm/aaaa)" style="font-size:6.5pt"/>
                        <br/>
                        <t:inputCalendar id="dataA" renderAsPopup="true" renderPopupButtonAsImage="true" popupDateFormat="dd/MM/yyyy" size="10" maxlength="10" styleClass="campoTesto" value="#{beanScadenziario.dataA}" required="true">
                            <s:convertDateTime type="date" pattern="dd/MM/yyyy"/>
                            <s:validateCompareTo operator="ge" for="dataDa" message="La prima data deve essere maggiore della seconda." />
                        </t:inputCalendar>
                        <br/>
                        <h:message style="color: red; font-size: 8pt" for="dataA" showDetail="true" showSummary="false" />
                    </td>
                    <td>
                        <t:commandButton value="Esegui" action="#{dettaglioScadenziario.calcolaNuovoPeriodo}"/>                                
                    </td>     
                </tr>   

                <tr>                       
                    <td bgcolor="#FFF06F"><em><strong>Imponibile Acquisto</strong></em></td>
                    <td bgcolor="#FFF06F"><em><strong>Imposta Acquisto</strong></em></td>
                    <td bgcolor="#DBEAFB"><em><strong>Imbonibile Vendita</strong></em></td>
                    <td bgcolor="#DBEAFB"><em><strong>Imposta Vendita</strong></em></td>
                    <td bgcolor="#C1E0C0"><em><strong>Differenza Iva</strong></em></td>
                    <td bgcolor="#F06150"><em><strong>Iva a credito</strong></em></td>                    
                </tr>

                <tr>
                    <td bgcolor="#FFF06F"><t:outputText id="imponibileAcquisto" value="#{beanScadenziario.imponibileAcquisto}" styleClass="dettaglio_InputText">                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText></td>
                    <td bgcolor="#FFF06F"><t:outputText id="impostaAcquisto"    value="#{beanScadenziario.impostaAcquisto}"    styleClass="dettaglio_InputText">                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText></td>
                    <td bgcolor="#DBEAFB"><t:outputText id="imponibileVendita"  value="#{beanScadenziario.imponibileVendita}"  styleClass="dettaglio_InputText">                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText></td>
                    <td bgcolor="#DBEAFB"><t:outputText id="impostaVendita"     value="#{beanScadenziario.impostaVendita}" styleClass="dettaglio_InputText">                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText></td>
                    <td bgcolor="#C1E0C0"><t:outputText id="differenzaIva"      value="#{beanScadenziario.differenzaIva}" styleClass="dettaglio_InputText">                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText></td>
                    <td bgcolor="#F06150"><strong><t:outputText id="ivaVersare"         value="#{beanScadenziario.ivaVersare}" styleClass="dettaglio_InputText">                  
                        <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                    </t:outputText></td></strong></td>
                </tr>
            
            </tbody>
        </table>
        <br />
        <t:panelTabbedPane serverSideTabSwitch="false" >             
                                                  
            <t:panelTab id="tabFattVend" label="Fatture di Vendita">                
                <f:verbatim><div  style="overflow: scroll; width:750px; height: 300px; white-space: nowrap; wrap: off"></f:verbatim>
                <t:dataTable id="listaScadenziarioFatt" var="lista" value="#{beanScadenziario.listaScadenziarioFatt}" preserveDataModel="true"           
                    styleClass="dataTableGestisci_Table2" 
                    headerClass="dataTableGestisci_Header"
                    rowClasses="dataTableGestisci_Row1, dataTableGestisci_Row2"          
                    columnClasses="dataTableGestisci_Column" 
                    rowOnMouseOver="this.style.backgroundColor='orange'"
                    rowOnMouseOut="this.style.backgroundColor=''">  
                
                    
                    <t:column width="20%">
                        <f:facet name="header"  >
                            <t:outputText value="CLIENTE" />
                        </f:facet>
                        <t:outputText value="#{lista.beanCliente.ragioneSociale}" /> 
                    </t:column>
                   
                    <t:column width="10%">                        
                        <f:facet name="header">
                            <t:outputText value="Data"/>
                        </f:facet>                        
                        <t:outputText value="#{lista.data}">
                            <f:convertDateTime pattern="dd/MM/yyyy" type="both" timeZone="Europe/Rome"/>
                        </t:outputText>              
                    </t:column>        
                    
                    <t:column width="10%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Numero" />
                        </f:facet>
                        <t:outputText value="#{lista.codice}" /> 
                    </t:column>
    
                    <t:column width="20%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imponibile"/>
                        </f:facet>
                        <t:outputText value="#{lista.imponibile}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>
                    
                    <t:column width="20%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imposta"/>
                        </f:facet>
                        <t:outputText value="#{lista.iva}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>
                
                    <t:column width="20%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Totale"/>
                        </f:facet>
                        <t:outputText value="#{lista.totale}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>                 
                 
                </t:dataTable>  
                <f:verbatim></div></f:verbatim>                           
            </t:panelTab>            
            
            <t:panelTab id="tabFattAcq" label="Fatture di Acquisto">                
                <f:verbatim><div  style="overflow: scroll; width:750px; height: 300px; white-space: nowrap; wrap: off"></f:verbatim>
                <t:dataTable id="listaScadenziarioAcq" var="lista" value="#{beanScadenziario.listaScadenziarioAcq}" preserveDataModel="true"           
                    styleClass="dataTableGestisci_Table2" 
                    headerClass="dataTableGestisci_Header"
                    rowClasses="dataTableGestisci_Row1, dataTableGestisci_Row2"          
                    columnClasses="dataTableGestisci_Column" 
                    rowOnMouseOver="this.style.backgroundColor='orange'"
                    rowOnMouseOut="this.style.backgroundColor=''">                  
                    
                    <t:column width="35%" >
                        <f:facet name="header"  >
                            <t:outputText value="FORNITORE" />
                        </f:facet>
                        <t:outputText value="#{lista.beanFornitore.ragioneSociale}" /> 
                    </t:column>
                    
                    <t:column width="10%">                        
                        <f:facet name="header">
                            <t:outputText value="Data"/>
                        </f:facet>                        
                        <t:outputText value="#{lista.data}">
                            <f:convertDateTime pattern="dd/MM/yyyy" type="both" timeZone="Europe/Rome"/>
                        </t:outputText>              
                    </t:column>   
                    
                    <t:column width="10%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Numero" />
                        </f:facet>
                        <t:outputText value="#{lista.numeroFattura}" /> 
                    </t:column>  
                    
                    <t:column width="15%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imponibile" />
                        </f:facet>
                        <t:outputText value="#{lista.imponibile}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>  
                    
                    <t:column width="15%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imposta" />
                        </f:facet>
                        <t:outputText value="#{lista.imposta}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>  
                    
                    <t:column width="15%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Totale" />
                        </f:facet>
                        <t:outputText value="#{lista.totale}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>  
                    
                </t:dataTable>  
                <f:verbatim></div></f:verbatim>                           
            </t:panelTab>         
            
            <t:panelTab id="tabVendBanc" label="Vendite al Banco">                
                <f:verbatim><div  style="overflow: scroll; width:750px; height: 300px; white-space: nowrap; wrap: off"></f:verbatim>
                <t:dataTable id="listaScadenziarioScon" var="lista" value="#{beanScadenziario.listaScadenziarioScon}" preserveDataModel="true"           
                    styleClass="dataTableGestisci_Table2" 
                    headerClass="dataTableGestisci_Header"
                    rowClasses="dataTableGestisci_Row1, dataTableGestisci_Row2"          
                    columnClasses="dataTableGestisci_Column" 
                    rowOnMouseOver="this.style.backgroundColor='orange'"
                    rowOnMouseOut="this.style.backgroundColor=''">  

                    <t:column width="20%">                        
                        <f:facet name="header">
                            <t:outputText value="Data"/>
                        </f:facet>                        
                        <t:outputText value="#{lista.data}">
                            <f:convertDateTime pattern="dd/MM/yyyy" type="both" timeZone="Europe/Rome"/>
                        </t:outputText>              
                    </t:column>                                     
                    
                    <t:column width="20%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Numero" />
                        </f:facet>
                        <t:outputText value="#{lista.numero}" /> 
                    </t:column>  
                    
                    <t:column width="20%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imponibile" />
                        </f:facet>
                        <t:outputText value="#{lista.imponibile}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>  
                    
                    <t:column width="15%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imposta" />
                        </f:facet>
                        <t:outputText value="#{lista.iva}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>  
                    
                    <t:column width="20%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Totale" />
                        </f:facet>
                        <t:outputText value="#{lista.totale}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>  
                    
                    <t:column width="15%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Numero pezzi" />
                        </f:facet>
                        <t:outputText value="#{lista.numProdotti}" /> 
                    </t:column>  
                    
                </t:dataTable>  
                <f:verbatim></div></f:verbatim>                           
            </t:panelTab>  
       
            <t:panelTab id="tabFattResi" label="Resi al Fornitore">                
                <f:verbatim><div  style="overflow: scroll; width:750px; height: 300px; white-space: nowrap; wrap: off"></f:verbatim>
                <t:dataTable id="listaScadenziarioResi" var="listaResi" value="#{beanScadenziario.listaScadenziarioResi}" preserveDataModel="true"           
                    styleClass="dataTableGestisci_Table2" 
                    headerClass="dataTableGestisci_Header"
                    rowClasses="dataTableGestisci_Row1, dataTableGestisci_Row2"          
                    columnClasses="dataTableGestisci_Column" 
                    rowOnMouseOver="this.style.backgroundColor='orange'"
                    rowOnMouseOut="this.style.backgroundColor=''">  
                
                    
                    <t:column width="20%">
                        <f:facet name="header"  >
                            <t:outputText value="Fornitore" />
                        </f:facet>
                        <t:outputText value="#{listaResi.beanFornitore.ragioneSociale}" /> 
                    </t:column>
                   
                    <t:column width="10%">                        
                        <f:facet name="header">
                            <t:outputText value="Data"/>
                        </f:facet>                        
                        <t:outputText value="#{listaResi.dataReso}">
                            <f:convertDateTime pattern="dd/MM/yyyy" type="both" timeZone="Europe/Rome"/>
                        </t:outputText>              
                    </t:column>        
                    
                    <t:column width="10%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Numero" />
                        </f:facet>
                        <t:outputText value="#{listaResi.codice}/R" /> 
                    </t:column>
    
                    <t:column width="20%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imponibile"/>
                        </f:facet>
                        <t:outputText value="#{listaResi.imponibile}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>
                    
                    <t:column width="20%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imposta"/>
                        </f:facet>
                        <t:outputText value="#{listaResi.iva}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>
                
                    <t:column width="20%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Totale"/>
                        </f:facet>
                        <t:outputText value="#{listaResi.totale}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>                 
                 
                </t:dataTable>  
                <f:verbatim></div></f:verbatim>                           
            </t:panelTab>
            
            <t:panelTab id="tabFattResiCliente" label="Resi al Cliente">                
                <f:verbatim><div  style="overflow: scroll; width:750px; height: 300px; white-space: nowrap; wrap: off"></f:verbatim>
                <t:dataTable id="listaScadenziarioResiCli" var="listaResi" value="#{beanScadenziario.listaScadenziarioResiCliente}" preserveDataModel="true"           
                    styleClass="dataTableGestisci_Table2" 
                    headerClass="dataTableGestisci_Header"
                    rowClasses="dataTableGestisci_Row1, dataTableGestisci_Row2"          
                    columnClasses="dataTableGestisci_Column" 
                    rowOnMouseOver="this.style.backgroundColor='orange'"
                    rowOnMouseOut="this.style.backgroundColor=''">  
                
                    
                    <t:column width="20%">
                        <f:facet name="header"  >
                            <t:outputText value="Cliente" />
                        </f:facet>
                        <t:outputText value="#{listaResi.beanCliente.ragioneSociale}" /> 
                    </t:column>
                   
                    <t:column width="10%">                        
                        <f:facet name="header">
                            <t:outputText value="Data"/>
                        </f:facet>                        
                        <t:outputText value="#{listaResi.dataReso}">
                            <f:convertDateTime pattern="dd/MM/yyyy" type="both" timeZone="Europe/Rome"/>
                        </t:outputText>              
                    </t:column>        
                    
                    <t:column width="10%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Numero" />
                        </f:facet>
                        <t:outputText value="#{listaResi.codice}/C" /> 
                    </t:column>
    
                    <t:column width="20%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imponibile"/>
                        </f:facet>
                        <t:outputText value="#{listaResi.imponibile}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>
                    
                    <t:column width="20%" style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Imposta"/>
                        </f:facet>
                        <t:outputText value="#{listaResi.iva}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>
                
                    <t:column width="20%"  style="text-align: right">
                        <f:facet name="header"  >
                            <t:outputText value="Totale"/>
                        </f:facet>
                        <t:outputText value="#{listaResi.totale}"> 
                            <s:convertNumber minIntegerDigits="1" maxFractionDigits="2" pattern="#,##0.00" />
                        </t:outputText>
                    </t:column>                 
                 
                </t:dataTable>  
                <f:verbatim></div></f:verbatim>                           
            </t:panelTab>
            
        </t:panelTabbedPane>    
    </h:form> 
    
    <h:form id="erroriDataBase" rendered="false">
        <f:verbatim><table><td align="left" class="messaggiErrore" height="2px"></f:verbatim>           
        <h:messages style="color: red" showDetail="true" showSummary="false"/>
        <f:verbatim></td></table></f:verbatim>
    </h:form>  
    
    <jsp:include page="/piePagina.jsp"/>      
</f:view>
